﻿using System;
using ExFlash.Records;

namespace ExFlash.Tags
{
    public class DoABCTag : Tag
    {
        private readonly int _swfVersion;
        
        public UInt32 Flags
        {
            get;
            private set;
        }

        public StringRecord Name
        {
            get;
            private set;
        }

        public Byte[] ABCData
        {
            get;
            private set;
        }

        public DoABCTag(int len, int version, Int32 offset)
            : base(TagCodes.DoABC, len, offset)
        {
            _swfVersion = version;
        }

        public override void SwfDeserialize(BinaryBitReader reader)
        {
            long startIndex = reader.Position;
            
            Flags = reader.ReadUInt32();

            Name = new StringRecord(_swfVersion);
            Name.SwfDeserialize(reader);

            int abcLength = TagLength - (int)(reader.Position - startIndex);
            ABCData = new Byte[abcLength];
            reader.Read(ABCData, 0, abcLength);
        }

        public override void SwfSerialize(byte[] arr, ref int offset)
        {
            throw new NotImplementedException();
        }
    }
}
